<!-- 新增和编辑弹窗 -->
<template>
  <a-modal
    :width="800"
    :visible="visible"
    title="详情"
    :body-style="{ paddingBottom: '8px' }"
    @update:visible="updateVisible"
    :footer="null"
  >
    <a-descriptions bordered :column="2" size="default">
      <a-descriptions-item label="设备ID">{{ form.recordId }}</a-descriptions-item>
      <a-descriptions-item label="推送类型">{{ formatType }}</a-descriptions-item>
      <a-descriptions-item label="推送情况">{{ formatSendResult }}</a-descriptions-item>
      <a-descriptions-item label="推送时间">{{ formatTime }}</a-descriptions-item>
      <a-descriptions-item label="执行信息" :span="2">{{ form.msg }}</a-descriptions-item>
    </a-descriptions>
    <a-divider/>
    <a-collapse :active-key="['1']">
      <a-collapse-panel key="1" header="推送命令(16进制)">
        <p>{{ form.sendContent }}</p>
      </a-collapse-panel>
    </a-collapse>
    <a-divider/>
    <a-collapse :active-key="['1']">
      <a-collapse-panel key="1" header="具体参数">
        <p>{{ form.updateData }}</p>
      </a-collapse-panel>
    </a-collapse>
  </a-modal>
</template>

<script>
  import { reactive, toRefs, watchEffect } from 'vue';
  import moment from 'moment';

  export default {
    name: 'DeviceManagerdeviceBasaCommandCmdConfigQueueDetail',
    emits: ['update:visible'],
    props: {
      // 弹窗是否打开
      visible: Boolean,
      // 详情数据
      data: Object
    },
    setup(props, context) {
      const data = reactive({
        form: {}
      });

      const watch = watchEffect(() => {
        if (props.data) {
          data.form = Object.assign({}, props.data);
        }
      });

      const updateVisible = value => {
        context.emit('update:visible', value);
      };

      return {
      ...toRefs(data),
      watch,
      updateVisible
      };
    },
    computed : {
      formatType : function () {
        if (this.form.sceneDictate == 1) {
          return "获取版本";
        } else if (this.form.sceneDictate == 2) {
          return "cancel profiles";
        } else if (this.form.sceneDictate == 3) {
          return "Profile1 start";
        } else if (this.form.sceneDictate == 4) {
          return "Profile1 stop";
        } else if (this.form.sceneDictate == 5) {
          return "Profile2 start";
        } else if (this.form.sceneDictate == 6) {
          return "Profile2 stop";
        } else if (this.form.sceneDictate == 7) {
          return "Profile3,Ramp start";
        } else if (this.form.sceneDictate == 8) {
          return "Profile3,Ramp stop";
        } else if (this.form.sceneDictate == 9) {
          return "Profile3,Frozen start";
        } else if (this.form.sceneDictate == 10) {
          return "Profile3,Frozen stop";
        } else if (this.form.sceneDictate == 11) {
          return "Profile3,Refrigerator start";
        } else if (this.form.sceneDictate == 12) {
          return "Profile3,Refrigerator stop";
        } else if (this.form.sceneDictate == 13) {
          return "Profile3,Room Temperature start";
        } else if (this.form.sceneDictate == 14) {
          return "Profile3,Room Temperature stop";
        } else if (this.form.sceneDictate == 15) {
          return "Profile4 start";
        } else if (this.form.sceneDictate == 16) {
          return "Profile4 stop";
        } else if (this.form.sceneDictate == 17) {
          return '获取状态';
        } else if (this.form.sceneDictate== 21) {
          return 'disconnect with Colostromat';
        } else if (this.form.sceneDictate == 22) {
          return 'connect with Colostromat';
        }
      },
      formatSendResult : function() {
        if (this.form.isSend == 0) {
          return '未推送';
        } else if (this.form.isSend == 1) {
          return '推送中';
        } else if (this.form.isSend == 2) {
          return '已推送';
        } else if (this.form.isSend == 3) {
          return '已推送';
        } else if (this.form.isSend == 4) {
          return '失败';
        } else {
          return '-';
        }
      },
      formatTime : function() {
        if (this.form.sendTime) {
          return moment(this.form.sendTime * 1000).format('YYYY-MM-DD HH:mm:ss')
        } else {
          return '-';
        }
      }
    }
  };
</script>

<style scoped></style>
